<template>
  <nav class="navbar">
    <div class="navbar-container">
      <router-link to="/" class="logo">
        <el-icon class="logo-icon"><Shop /></el-icon>
        <span>宠物服务商城</span>
      </router-link>
      
      <div class="nav-links">
        <router-link to="/services" class="nav-link">服务列表</router-link>
        <router-link to="/profile" class="nav-link">个人中心</router-link>
        <router-link to="/orders" class="nav-link">我的订单</router-link>
      </div>

      <div class="auth-buttons">
        <template v-if="!isLoggedIn">
          <router-link to="/login" class="btn btn-login">登录</router-link>
          <router-link to="/register" class="btn btn-register">注册</router-link>
        </template>
        <template v-else>
          <el-dropdown>
            <span class="user-profile">
              <el-icon class="avatar"><User /></el-icon>
              {{ username }}
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人设置</el-dropdown-item>
                <el-dropdown-item>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </template>
      </div>
    </div>
  </nav>
</template>

<script>
import { Shop, User } from '@element-plus/icons-vue'

export default {
  name: 'NavBar',
  components: {
    Shop,
    User
  },
  data() {
    return {
      isLoggedIn: false,
      username: '用户名'
    }
  }
}
</script>

<style scoped>
.navbar {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 1rem 0;
  position: fixed; 
  left: 0;
  top: 0;
  width: 100%;
  z-index: 100; 
  height: 64px; 
}


.navbar-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #333;
}

.logo img {
  height: 40px;
  margin-right: 10px;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-link {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  transition: color 0.3s;
}

.nav-link:hover {
  color: #409EFF;
}

.auth-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 8px 16px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
}

.btn-login {
  color: #409EFF;
  border: 1px solid #409EFF;
}

.btn-register {
  background-color: #409EFF;
  color: white;
}

.user-profile {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.avatar {
  font-size: 24px;
  color: #666;
  margin-right: 8px;
}

.logo-icon {
  font-size: 32px;
  color: #409EFF;
  margin-right: 10px;
}
</style> 